cmake_minimum_required(VERSION 3.22)

project(SOLDIERFIRE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall")
# 创建的build文件夹的上层文件夹创建bin文件夹，也就是根目录下创建bin文件夹用来存放可执行文件
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(OpenCV_DIR "/home/icebot/Lib/OpenCV_install/lib/cmake/opencv4")
find_package(OpenCV REQUIRED)
# 包含OpenCV头文件
include_directories(${OpenCV_INCLUDE_DIRS})

# 头文件所在地
include_directories(include)

# 库文件所在地
add_subdirectory(src)

# 对生成的可执行文件命名
set(EXECUTABLE_NAME test)
# 选中工作空间中需要调用的测试文件
set(WORKING_DIRECTORY
  # work/main.cpp
  work/test_search.cpp
)

# 生成可执行文件
add_executable(${EXECUTABLE_NAME} ${WORKING_DIRECTORY})
# 将生成的可执行文件对OpenCV库进行链接
target_link_libraries(${EXECUTABLE_NAME} ${OpenCV_LIBS})

#将生成的可执行文件对库文件进行链接
target_link_libraries(${EXECUTABLE_NAME} libcpp)